package com.cjl.multi_thread.share_cooperate;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MultiStartThread {
    public static void main(String[] args) {
        new MThread().start();

        new Thread(new MRunnable()).start();

        FutureTask<String> futureTask = new FutureTask<String>(new MCallable());
        new Thread(futureTask).start();
        try {
            System.out.println("MultiStartThread.main "+futureTask.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }


    }


    static class MThread extends Thread{
        @Override
        public void run() {
            System.out.println("MThread.run");
        }
    }

    static class MRunnable implements Runnable {
        @Override
        public void run() {
            System.out.println("MRunnable.run");
        }
    }

    static class MCallable implements Callable<String>{

        @Override
        public String call() throws Exception {
            return "result";
        }
    }
}
